//页面操作相关
export class PageUtils {

    /**
     * 锚点跳转函数
     * @param id 锚点->#id
     * @param instance vue组件实例对象->this
     */
    static pageScrollTo(id,instance) {
        const query = uni.createSelectorQuery().in(instance);
        query.select(id).boundingClientRect();
        query.exec((res) => {
            if (res && res[0]) {
                const scrollTop = res[0].top;
                console.log(res[0].top)
                uni.pageScrollTo({
                    scrollTop,
                    duration: 300
                });
            }
        });
    }

    /**
     * 立即回到顶部,duration为0，无滚动效果
     */
    static pageScrollToTop(){
        uni.pageScrollTo({
            scrollTop:0,
            duration: 0
        })
    }
}
